﻿using SUNRPA.CONTROLS.IMPL.domain.attrubutes;
using SUNRPA.CONTROLS.IMPL.domain.flowRunningVar;
using SUNRPA.CONTROLS.IMPL.util;
using System.Collections.Concurrent;

namespace SUNRPA.CONTROLS.IMPL.domain.flowItemParam {
    [Serializable]
    [VarFieldName("OutListName")]
    public class TextCut2ListNParam:BaseParam {
        private string inputText = "";
        //分隔符0标准分割符，1自定义分隔符（暂时不做）
        private int separation = 0;
        //0空格、1制表、2换行
        private int standerSepType = 0;
        //自定义分隔符符号
        private string customSepString = "";
        //自定义分隔符是否为正则表达式
        private bool isRegx = false;
        //是否过滤空白项
        private bool filterEmpty = true;
        //分割结果保存名称
        private string outListName = "textSplitList";

        public string InputText {
            get => inputText; 
            set { 
                inputText = value;
                NotifyPropertyChanged("InputText");
            }  
        }
        public string CustomSepString {
            get => customSepString; 
            set { 
                customSepString = value;
                NotifyPropertyChanged("CustomSepString");
            }
        }

        public string OutListName {
            get => outListName; 
            set { 
                outListName = value;
                NotifyPropertyChanged("OutListName");
            }
        }
        public int Separation {
            get => separation; 
            set { 
                separation = value;
                NotifyPropertyChanged("Separation");
            }  
        }

        public int StanderSepType {
            get => standerSepType; 
            set { 
                standerSepType = value;
                NotifyPropertyChanged("StanderSepType");
            }  
        }

        public bool IsRegx {
            get => isRegx; 
            set { 
                isRegx = value;
                NotifyPropertyChanged("IsRegx");
            }  
        }

        public bool FilterEmpty {
            get => filterEmpty; 
            set { 
                filterEmpty = value;
                NotifyPropertyChanged("FilterEmpty");
            }  
        }

        public string GetTranslateSeparation() {
            switch(this.separation) {
                case 0:
                    return "标准分隔符";
                case 1:
                    return "自定义分割符";
                default : return "标准分隔符";
            }
        }


        public string GetTranslateStanderSepType() {
            switch(this.standerSepType) {
                case 0:
                    return "空格";
                case 1:
                    return "制表符";
                case 2:
                    return "换行符";
                default : return "空格";
            }
        }

        public override void SetLatestVarName(ConcurrentDictionary<string, ConcurrentDictionary<string, RPAVariableDefineWrapper>> globleData) {
            this.outListName = this.GetLatestName(this.outListName, globleData);
        }
    }
}
